<?php  if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class Translate_model extends My_Model
{    
    public function __construct()
    {
        parent::__construct();
        $this->model_name="属性翻译库";
        $this->tablename="translate";  
    }
        
  

    public function getall($key=""){
        if($key)
        {
            $wkey=["og"=>$key,"trans"=>$key];
        }
        else
        {
            $wkey=[];
        }
        return $this->get_items_by_where([],"",$wkey);
    }


    public function get_by_key($key){

        $where=array("og"=>$key);
        return $this->get_item_by_where($where);

    }

    public function update($id,$data){
        if(is_array($id))
        {
            $where="id in (".implode(",",$id).")";
           
        }else{
            $where=array("id"=>$id);
           
        }
        return $this->update_item($where,$data);
    }

    
    public function create($data){
        if(!$this->get_by_key($data["og"]))
        {
            return $this->add_item($data);
        }
        else
        {
            return false;
        }        
    }
}